﻿using System.Globalization;

namespace Compass.Maui.Converters;

public class RolesToVisibilityConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var preferenceService = Ioc.Default.GetRequiredService<IPreferenceService>();
        var role = preferenceService.Get(Consts.Role, string.Empty);

        return string.IsNullOrEmpty(role)?  Visibility.Hidden  :value.ToString()!.Contains(role) ? Visibility.Visible : Visibility.Hidden;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}